<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增案件信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-info-add">
            <!-- <input name="deptId" type="hidden" id="treeId"/> -->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">案件名称：</label>
                <div class="col-sm-8">
                    <input name="caseName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">委托方：</label>
                <div class="col-sm-8">
                   <div class="input-group">
						<div class="input-group">
							<input name="custId" type="hidden" id="custId"/>
							<input name="certNo" type="hidden" id="certNo"/>
							<input name="custName" type="hidden" id="custName"/>
						</div>
                    	<input name="custSelect" id="custSelect" type="text" placeholder="请选择客户" class="form-control" readonly>
                    	<!-- <input name="caseName" id="treeName" type="text" placeholder="请选择归属部门" class="form-control"> -->
                    	<!-- <input name="deptName" id="treeName" onclick="selectDeptTree()" type="text" placeholder="请选择归属部门" class="form-control"> -->
                    	<span class="input-group-addon" onclick="selectUserInfo()"><i class="fa fa-search"></i></span>
                	</div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">利益相对方：</label>
                <div class="col-sm-8">
                    <input name="caseName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">第三方：</label>
                <div class="col-sm-8">
                    <input name="caseName" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">案件类型：</label>
                <div class="col-sm-8">
                    <div class="input-group">
						<input name="caseTypeId" type="text" required>
						&nbsp;&nbsp;&nbsp;&nbsp;诉讼类型：
						<input name="litigateTypeId" type="text">
                	</div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">案件类型：</label>
                    <div id="element_ct" class="row">
                        <div class="col-sm-2">
                            <select class="type form-control m-b" data-first-title="请选择">
			                  <option value="">请选择</option>
			                </select>
		                </div>
                        <div class="col-sm-2">
						&nbsp;&nbsp;&nbsp;&nbsp;诉讼类型：
		                </div>
		                <div class="col-sm-2">
			                <select class="router form-control m-b" data-first-title="请选择">
			                  <option value="">请选择</option>
			                </select>
		                </div>
						
                	</div>
            </div>
			<div class="ibox-content">
                        <p>简单联动示例。</p>
                        <div id="element" class="row">
                            <div class="col-sm-2">
	                            <select class="type form-control m-b" data-first-title="请选择">
				                  <option value="">请选择</option>
				                </select>
			                </div>
			                <div class="col-sm-2">
				                <select class="router form-control m-b" data-first-title="请选择">
				                  <option value="">请选择</option>
				                </select>
			                </div>
                        </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jquery-cxselect-js" />
    <script th:inline="javascript">
        var prefix = ctx + "biz/info"
        $("#form-info-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-info-add').serialize());
            }
        }
        
        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
        	var treeId = $("#treeId").val();
        	var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        	var url = ctx + "system/user/selectDeptTree/" + deptId;
			var options = {
				title: '选择部门',
				width: "380",
				url: url,
				callBack: doSubmit
			};
			$.modal.openOptions(options);
		}
		
		function doSubmit(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#treeId").val(body.find('#treeId').val());
   			$("#treeName").val(body.find('#treeName').val());
   			$.modal.close(index);
		}
        
        /* 用户管理-新增-选择部门树 */
        function selectUserInfo() {
        	var url = ctx + "crm/custinfo/choice";
			var options = {
				title: '选择客户',
				width: "680",
				url: url,
				callBack: doSubmitUserInfo
			};
			$.modal.openOptions(options);
		}
		
		function doSubmitUserInfo(index, layero){
			var body = $.modal.getChildFrame(index);
   			$("#custId").val(body.find('#custId').val());
   			$("#custName").val(body.find('#custName').val());
   			$("#certNo").val(body.find('#certNo').val());
   			/* $("#custSelect").val($("#custId").val() + '-' + $("#custName").val() + '-' + $("#certNo").val()); */
   			$("#custSelect").val($("#custName").val() + '-' + $("#certNo").val());
   			$.modal.close(index);
		}
		
        // 直接返回获取
   		var data = [[${data}]];
    	$('#element').cxSelect({
    	  selects: ['type', 'router'],
    	  jsonValue: 'v',
    	  data: data
    	});
		
        // 直接返回获取
   		var ctData = [[${ctData}]];
    	$('#element_ct').cxSelect({
    	  selects: ['type', 'router'],
    	  jsonValue: 'v',
    	  data: ctData
    	});

    </script>
</body>
</html>